package projetolions;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;


public class TesteMenu extends javax.swing.JFrame {

    public TesteMenu() {
        super ("Menu");

        JMenu arquivoMenu = new JMenu("Arquivo");
        arquivoMenu.setMnemonic('A');

        JMenuItem novoItem = new JMenuItem("Novo");
        novoItem.setMnemonic('N');
        arquivoMenu.add(novoItem);

        novoItem.addActionListener(
                new ActionListener() {

            public void actionPerformed(ActionEvent e)
            {
               JOptionPane.showMessageDialog( TesteMenu.this,
                       "Exemplo","Novo",JOptionPane.PLAIN_MESSAGE);
            }
        });

         JMenuItem sairItem = new JMenuItem("Sair");
         sairItem.setMnemonic('S');
         arquivoMenu.add(sairItem);

         arquivoMenu.addActionListener(
                 new ActionListener() {

            public void actionPerformed(ActionEvent r) {
                       System.exit(0);
            }
        });

         JMenuBar menuBar = new JMenuBar();
         setJMenuBar(menuBar);
         menuBar.add(arquivoMenu);

        initComponents();
    }

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">
    private void initComponents() {

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        pack();
    }// </editor-fold>

    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new TesteMenu().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify
    // End of variables declaration

}
